package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"image"
	"image/jpeg"
	"io/ioutil"
	"log"
	"net/http"
)

func main() {
	//打开图像
	f, err := os.Open("D:\\Documents\\Pictures\\1234.jpg")
	//编码
	if err != nil {
		panic(err)
	}
	defer f.Close()
	f
	m, err := jpeg.Decode(f)
	if err != nil {
		panic(err)
	}

	bounds := m.Bounds()
	p := image.NewRGBA(bounds)

	body := bytes.NewBuffer([]byte(b))
	res, err := http.Post("http://127.0.0.1:8080/echo", "application/json;charset=utf-8", body)
	defer res.Body.Close()
	if err != nil {
		log.Fatal(err)
		return
	}

	hander := res.Header
	log.Println("----------header----------")
	for k, v := range hander {
		log.Printf("%s:%s\n", k, v[0])
	}
	result, err := ioutil.ReadAll(res.Body)

	if err != nil {
		log.Fatal(err)
		return
	}
	fmt.Printf("%s", result)
}
